﻿@using ENail.Portal.Web.Models
@using Equation.Enterprise.Framework.Web.Model
@using MvcContrib.Pagination
@using MvcContrib.UI.Pager
@using MvcContrib.UI.Grid
@model GenericListViewModel<EmployeeListViewItem>

@{
    ViewBag.Title = "Employees Management";
    Layout = "~/Views/Shared/_Layout.cshtml";
}


    @using (Html.BeginForm())
    {
    <table>
        <tr>
            <td><input type="button" value="Add new employee" onclick="document.location='@Url.Action("Add")'" /></td>
            <td align="right" width="150px">Employee Name:</td>
            <td>@Html.TextBoxFor(x => x.Filter)</td>
            <td><input type="submit" value="Search" /></td>
        </tr>
    </table>

    <table>
        <tr>
            <td align="right">
                @Html.Pager((IPagination)Model.List).Link(page => Url.Action("List", new { page = page, filter = Model.Filter }))
            </td>
        </tr>
        <tr>
            <td>
                @Html.Grid(Model.List).Columns((column) =>
                                                {
                                                    column.For(x => x.FirstName)
                                                            .Named("FirstName")
                                                            .Attributes(width => "200px");
                                                    column.For(x => x.LastName)
                                                            .Named("LastName")
                                                            .Attributes(width => "150px");
                                                    column.For(x => x.Phone)
                                                            .Named("Phone")
                                                            .Attributes(width => "150px");
                                                    column.For(x => x.CommisionPercentage)
                                                            .Named("CommisionPercentage")
                                                            .Attributes(width => "150px");
                                                }
                                        ).Attributes(@class => "grid"
                                        ).HeaderRowAttributes(new Dictionary<string, object> { { "class", "gridheaderrow" } }
                                        ).RowAttributes(row => new Dictionary<string, object> { { "onclick", "document.location='" + Url.Action("Update", new { Id = row.Item.Id }) + "'"} })
            </td>
        </tr>
        <tr>
            <td align="right">

            </td>
        </tr>
    </table>
    }
